<?php
/**
 * Created by PhpStorm.
 * User: 刘芳
 * Date: 2019/3/31
 * Time: 17:26
 */

namespace app\api\controller\v1;
use app\api\model\Theme as ThemeModel;


use app\api\validate\IDCollection;
use app\api\validate\IDMustBeInt;
use app\lib\exception\ThemeException;

class Theme
{
    public function getSimpleList($ids='')
    {
        (new IDCollection())->goCheck();
        $ids = explode(',',$ids);
        $result = ThemeModel::with("topicImg,headImg")->select($ids);
        if($result->isEmpty())
        {
            throw new ThemeException();
        }
        return json($result);
    }


    public function getComplexOne($id)
    {
        (new IDMustBeInt())->goCheck();
        $theme = ThemeModel::getThemeWithProducts($id);
        if(!$theme)
        {
            throw new ThemeException();
        }
        return json($theme);

    }
}